package day06.dto;

import java.util.Comparator;

/**
 * @Auther: sky
 * @Date: 2019/2/28 23:23
 * @Description:
 */
public class Student implements Comparator{

    private String name;
    private int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compare(Object o1, Object o2) {
        Student student1 = (Student)o1;
        Student student2 = (Student)o2;

        int num = student1.getName().compareTo(student2.getName());

        return 0==num?new Integer(student1.getAge()).compareTo(new Integer(student2.getAge())):num;
    }
}
